package com.four.dailymanage.chamber.controller;

import com.four.dailymanage.chamber.entity.Chamber;
import com.four.dailymanage.chamber.service.ChamberService;
import com.four.dailymanage.common.bean.ResponseData;
import com.four.dailymanage.common.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@CrossOrigin
@RestController
@RequestMapping("/chamber")
public class ChamberController extends BaseController {
    @Autowired
    ChamberService chamberService;

    /**
     * 分页查询
     * @param pageNum
     * @param pageSize
     * @param cname
     * @param cno
     * @return
     */
    @GetMapping("/page")
    public ResponseData<Object> chamberPage(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "cname",required = false) String cname,
            @RequestParam(value = "cno",required = false) String cno,
            @RequestParam(value = "status",required = false)String status
    ){
        return returnObject(chamberService.getPageChamber(pageNum, pageSize, cname, cno,status));
    }

    /**
     * 添加会议室
     * @param chamber
     * @return
     */
    @PostMapping("/add")
    public ResponseData<Boolean> addCham(@RequestBody Chamber chamber){
        return returnBoolean(chamberService.addChamber(chamber));
    }

    /**
     * 根据id删除会议室
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    public ResponseData<Boolean> delCham(@PathVariable("id")Integer id){
        return returnBoolean(chamberService.delChamber(id));
    }

    /**
     * 修改 会议室的状态
     * @param chamber
     * @return
     */
    @PutMapping("/update")
    public ResponseData<Boolean> updCham(@RequestBody Chamber chamber){
        return  returnBoolean(chamberService.updChamber(chamber));
    }

}
